package com.onehouse.trigger.listener;

import com.google.common.eventbus.EventBus;
import com.google.common.eventbus.Subscribe;
import com.onehouse.domain.checkIn.adapter.event.CheckInPaymentPostMessageEvent;
import com.onehouse.domain.payment.service.IPaymentRequestService;
import jakarta.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class CheckInPaymentPostListener {

    @Autowired
    private IPaymentRequestService paymentService;
    
    @Autowired
    private EventBus eventBus;

    @PostConstruct
    public void init() {
        eventBus.register(this);
    }

    @Subscribe
    public void handleEvent(CheckInPaymentPostMessageEvent event) {
        // 处理"入住订单支付发起消息"
        paymentService.handleOrderPaymentPostEvent(event.getCheckInOrderId(), event.getTotalAmount());
    }
}
